import 'package:http/http.dart' as http;
import 'dart:convert';

// https://httpbin.org/ip 返回ip地址

Future getIpAddress() async {
  final url = Uri.parse('https://httpbin.org/ip');

  final response = await http.get(url);
  String ip = jsonDecode(response.body)['origin'];
  return ip;
}

void main(List<String> args) async {
  try {
    final ip = await getIpAddress();
    print(ip);
  } catch (err) {
    print(err);
  }
}
